# Much to organize
set (core_unsorted
    classfactory.cpp
    femcmpnn.cpp domain.cpp timestep.cpp metastep.cpp gausspoint.cpp
    cltypes.cpp timer.cpp dictionary.cpp heap.cpp grid.cpp
    connectivitytable.cpp error.cpp mathfem.cpp logger.cpp util.cpp
    initmodulemanager.cpp initmodule.cpp initialcondition.cpp
    assemblercallback.cpp
    homogenize.cpp
    nonlocalbarrier.cpp
    geotoolbox.cpp geometry.cpp
    datastream.cpp
    set.cpp
    weakperiodicbc.cpp
    solutionbasedshapefunction.cpp
    fracturemanager.cpp
    neumannmomentload.cpp
    parallelcontext.cpp
    contact/contactmanager.cpp
    contact/contactdefinition.cpp
    contact/contactelement.cpp
    prescribedmean.cpp
    bctracker.cpp
    # Semi sorted:
    errorestimator.cpp meshqualityerrorestimator.cpp remeshingcrit.cpp
    sloangraph.cpp sloangraphnode.cpp sloanlevelstruct.cpp
    eleminterpunknownmapper.cpp primaryunknownmapper.cpp materialmappingalgorithm.cpp
    nonlocalmaterialext.cpp randommaterialext.cpp
    inputrecord.cpp oofemtxtinputrecord.cpp dynamicinputrecord.cpp
    dynamicdatareader.cpp oofemtxtdatareader.cpp tokenizer.cpp parser.cpp
    spatiallocalizer.cpp dummylocalizer.cpp octreelocalizer.cpp
    integrationrule.cpp gaussintegrationrule.cpp lobattoir.cpp
    smoothednodalintvarfield.cpp dofmanvalfield.cpp
    # Deprecated?
    rowcol.cpp skyline.cpp skylineu.cpp
    ldltfact.cpp
    inverseit.cpp subspaceit.cpp gjacobi.cpp
    #
    symcompcol.cpp compcol.cpp
    unstructuredgridfield.cpp
    )

#oofegutils

if (USE_SPOOLES)
    list (APPEND core_unsorted spoolessparsemtrx.cpp spoolessolver.cpp)
endif ()

if (USE_IML)
    list (APPEND core_unsorted
        iml/dyncomprow.cpp iml/dyncompcol.cpp
        iml/precond.cpp iml/voidprecond.cpp iml/icprecond.cpp iml/iluprecond.cpp iml/ilucomprowprecond.cpp iml/diagpre.cpp
        iml/imlsolver.cpp
        )
endif ()

if (USE_T3D)
    list (APPEND core_unsorted
        T3d/src/t3d.c T3d/src/option.c T3d/src/error.c T3d/src/list.c T3d/src/draw.c T3d/src/draw1.c T3d/src/draw2.c T3d/src/drawpc.c
		T3d/src/vertex.c T3d/src/vertex1.c T3d/src/region.c T3d/src/patch.c T3d/src/shell.c T3d/src/bernstein.c T3d/src/ctrlpoint.c
		T3d/src/curve.c T3d/src/curve1.c T3d/src/curve2.c T3d/src/curve3.c 
		T3d/src/surface.c T3d/src/surface1.c T3d/src/surface2.c T3d/src/surface3.c 
		T3d/src/input.c T3d/src/input1.c T3d/src/input2.c T3d/src/input3.c T3d/src/input4.c T3d/src/input5.c T3d/src/input6.c 
		T3d/src/octree.c T3d/src/octree1.c T3d/src/octree2.c T3d/src/domain.c T3d/src/element.c 
		T3d/src/discret.c T3d/src/discret1.c T3d/src/discret2.c T3d/src/discret3.c 
		T3d/src/discret4.c T3d/src/discret5.c T3d/src/discret6.c 
		T3d/src/smooth.c T3d/src/smooth1.c T3d/src/quality.c T3d/src/renum.c T3d/src/output.c T3d/src/output1.c
        )
endif ()

if (USE_SLEPC)
    list (APPEND core_unsorted slepcsolver.cpp)
endif ()

if (USE_SUPERLU_MT)
  list (APPEND core_unsorted superlusolver.cpp)
endif ()


set (core_oofeg oofeggraphiccontext.cpp)

set (core_nodalrecovery
    nodalrecoverymodel.cpp
    zznodalrecoverymodel.cpp
    nodalaveragingrecoverymodel.cpp
    sprnodalrecoverymodel.cpp
    )

set (core_dofs
    dof.cpp
    masterdof.cpp
    simpleslavedof.cpp
    slavedof.cpp
    activedof.cpp
    )

set (core_nm
    sparselinsystemnm.cpp
    sparsenonlinsystemnm.cpp
    nrsolver.cpp
    dynamicrelaxationsolver.cpp
    linesearch.cpp
    calmls.cpp
    staggeredsolver.cpp
    )

if (USE_PETSC)
    list (APPEND core_nm petscsolver.cpp petscsparsemtrx.cpp)
endif ()

if (USE_INTEL_MKL_PARDISO)
    list (APPEND core_nm mklpardisosolver.cpp)
endif ()

if (USE_PARDISO_ORG)
  list (APPEND core_nm pardisoprojectorgsolver.cpp)
endif ()


set (core_fields
    fieldmanager.cpp
    field.cpp
    primaryfield.cpp
    intvarfield.cpp
    maskedprimaryfield.cpp
    dofdistributedprimaryfield.cpp
    uniformgridfield.cpp
    )

set (core_ltf
    function.cpp
    scalarfunction.cpp
    constantfunction.cpp
    heavisidetimefunction.cpp
    peakfunction.cpp
    piecewiselinfunction.cpp
    periodicpiecewiselinfunction.cpp
    calculatorfunction.cpp
    localgaussianrandomfunction.cpp
    interpolatingfunction.cpp
    )

set (core_cs
    crosssection.cpp
    emptycs.cpp
    )

set (core_td
    particletopologydescription.cpp
    )

set (core_dofman
    dofmanager.cpp
    node.cpp
    slavenode.cpp
    hangingnode.cpp
    qcnode.cpp
    rigidarmnode.cpp
    elementinternaldofman.cpp
    elementside.cpp
    )

set (core_material
    material.cpp
    dummymaterial.cpp
    )

set (core_export
    outputmanager.cpp
    exportmodule.cpp
    exportmodulemanager.cpp
    outputexportmodule.cpp
    errorcheckingexportmodule.cpp
    vtkexportmodule.cpp
    vtkxmlexportmodule.cpp
    homexportmodule.cpp
    matlabexportmodule.cpp
    gpexportmodule.cpp
    )

set (core_iga
    iga/iga.cpp
    iga/feibspline.cpp
    iga/feinurbs.cpp
    iga/feitspline.cpp
    )

set (core_arrays
    intarray.cpp
    floatarray.cpp
    floatmatrix.cpp
    )

set (core_engng
    engngm.cpp
    staggeredproblem.cpp
    )

set (core_element
    element.cpp
    )

set (core_fei
    feinterpol.cpp
    feinterpol1d.cpp
    feinterpol2d.cpp
    feinterpol3d.cpp
    fei1dlin.cpp
    fei1dquad.cpp
    fei1dhermite.cpp
    fei2dtrlin.cpp
    fei2dtrquad.cpp
    fei2dlinehermite.cpp
    fei2dlinelin.cpp
    fei2dlinequad.cpp
    fei2dquadconst.cpp
    fei2dquadlin.cpp
    fei2dquadquad.cpp
    fei2dquadbiquad.cpp
    fei3dlinelin.cpp
    fei3dtrlin.cpp
    fei3dtrquad.cpp
    fei3dtetlin.cpp
    fei3dtetquad.cpp
    fei3dhexalin.cpp
    fei3dhexaquad.cpp
    fei3dhexatriquad.cpp
    fei3dwedgelin.cpp 
    fei3dwedgequad.cpp
    )

set (core_xfem
    xfem/delaunay.cpp
    xfem/xfemelementinterface.cpp
    xfem/enrichmentfunction.cpp
    xfem/xfemmanager.cpp
    xfem/enrichmentitem.cpp
    xfem/geometrybasedei.cpp
    xfem/hybridei.cpp
    xfem/directei.cpp
    xfem/listbasedei.cpp
    xfem/inclusion.cpp
    xfem/patchintegrationrule.cpp
    xfem/propagationlaw.cpp
    xfem/XFEMDebugTools.cpp
    xfem/enrichmentfronts/enrichmentfront.cpp
    xfem/enrichmentfronts/enrichmentfrontdonothing.cpp
    xfem/enrichmentfronts/enrichmentfrontextend.cpp
    xfem/enrichmentfronts/enrichmentfrontreducefront.cpp
    xfem/enrichmentfronts/enrichmentfrontlinbranchfuncradius.cpp
    xfem/enrichmentfronts/enrichmentfrontlinbranchfunconeel.cpp
    xfem/enrichmentfronts/enrichmentfrontcohesivebranchfunconeel.cpp
    xfem/enrichmentfronts/enrichmentfrontintersection.cpp
    xfem/integrationrules/discsegintegrationrule.cpp
    xfem/xfemtolerances.cpp
    xfem/nucleationcriterion.cpp
    )

set (core_parallel
    communicator.cpp
    processcomm.cpp
    problemcomm.cpp
    combuff.cpp
    domaintransactionmanager.cpp
    parallelordering.cpp
    dyncombuff.cpp
    loadbalancer.cpp
    wallclockloadbalancermonitor.cpp
    nonlocalmatwtp.cpp
    )

if (USE_PARMETIS)
    list (APPEND core_parallel parmetisloadbalancer.cpp)
endif ()

set (core_bc
    generalboundarycondition.cpp
    boundarycondition.cpp
    prescribedgradienthomogenization.cpp
    prescribedgradient.cpp
    prescribedgradientbcneumann.cpp
    prescribedgradientbcweak.cpp
    prescribedgradientbcweakperiodic.cpp
    prescribedgradientbcweakdirichlet.cpp
    prescribedgradientbcperiodic.cpp
    mixedgradientpressurebc.cpp
    mixedgradientpressuredirichlet.cpp
    mixedgradientpressureneumann.cpp
    mixedgradientpressureweakperiodic.cpp
    load.cpp
    boundaryload.cpp
    pointload.cpp
    linearedgeload.cpp
    constantedgeload.cpp
    constantsurfaceload.cpp
    nodalload.cpp
    deadweight.cpp
    reinforcement.cpp
    surfacetensionbc.cpp
    linearconstraintbc.cpp
    )

if (USE_PYTHON)
    list (APPEND core_bc userdefdirichletbc.cpp)
    list (APPEND core_unsorted pythonexpression.cpp)
endif ()

set (core_mapping
    mmaclosestiptransfer.cpp
    mmashapefunctprojection.cpp
    mmaleastsquareprojection.cpp
    mmacontainingelementprojection.cpp
    matstatmapperint.cpp
    )

set (core_mesher
    t3dinterface.cpp
    targe2interface.cpp
    freeminterface.cpp
    subdivision.cpp
    trianglemesherinterface.cpp
    )

set (core
    ${core_unsorted}
    ${core_nodalrecovery}
    ${core_dofs}
    ${core_nm}
    ${core_td}
    ${core_fields}
    ${core_dofman}
    ${core_material}
    ${core_export}
    ${core_ltf}
    ${core_cs}
    ${core_arrays}
    ${core_engng}
    ${core_element}
    ${core_fei}
    ${core_xfem}
    ${core_bc}
    ${core_iga}
    ${core_mesher}
    ${core_mapping}
    )

if (USE_PARALLEL)
    list (APPEND core ${core_parallel})
endif ()

if (USE_OOFEG)
    list (APPEND core ${core_oofeg})
endif ()

file(GLOB_RECURSE project_headers *.h)
file(GLOB_RECURSE project_cpps *.cpp)
set(all_files ${project_headers} ${project_cpps})
source_group_by_dir(all_files)

add_library (core
    ${LIB_TYPE}
    ${core}
    ${project_headers}
    )
